﻿using HK.Core.Serializable.Protocol.Data;
using HK.Editor.Common;
using HK.Editor.Settings.Data;
using HK.Editor.Settings.Protocol.Data;
using UnityEngine;

namespace HK.Editor.Settings
{
    /// <summary>
    /// 打包配置
    /// </summary>
    [CreateAssetMenu(fileName = EditorConst.SASSET_FILE_BUILD_CONF, menuName = EditorConst.MENU_TXT_BUILD_CONF, order = (int)EditorConst.EditorConstMenuPriority.BuildConf)]
    public class BuildConf : SESettings<BuildConf, BuildConfData>, IBuildConf<BuildConfData>
    {
        /// <summary>
        /// 保护构造函数
        /// </summary>
        protected BuildConf() : base(true) { }

        /// <summary>
        /// 本地输出目录
        /// </summary>
        public string OutputDir => Body?.OutputDir;

#region App

        /// <summary>
        /// App版本
        /// </summary>
        public ISAssetVersion AppVersion => Body?.AppVersion;

        /// <summary>
        /// 重置App版本
        /// </summary>
        /// <param name="iVersion">App版本</param>
        /// <returns>true:有变化; false:无变化;</returns>
        public bool ResetAppVersion(string iVersion) => Body?.ResetAppVersion(iVersion) ?? false;

#endregion

#region Resource

        /// <summary>
        /// 母包版本
        /// </summary>
        public ISAssetVersion OriginVersion => Body?.OriginVersion;

        /// <summary>
        /// 重置母包版本
        /// </summary>
        /// <param name="iVersion">母包版本</param>
        /// <returns>true:有变化; false:无变化;</returns>
        public bool ResetOriginVersion(string iVersion) => Body?.ResetOriginVersion(iVersion) ?? false;
        
        /// <summary>
        /// 上一母包版本
        /// </summary>
        public ISAssetVersion LastOriginVersion => Body?.LastOriginVersion;

        /// <summary>
        /// 重置上一次母包版本
        /// </summary>
        /// <param name="iVersion">母包版本</param>
        /// <returns>true:有变化; false:无变化;</returns>
        public bool ResetLastOriginVersion(string iVersion) => Body?.ResetLastOriginVersion(iVersion) ?? false;
        
        /// <summary>
        /// 补丁版本
        /// </summary>
        public ISAssetVersion PatchVersion => Body?.PatchVersion;

        /// <summary>
        /// 重置补丁版本
        /// </summary>
        /// <param name="iVersion">母包版本</param>
        /// <returns>true:有变化; false:无变化;</returns>
        public bool ResetPatchVersion(string iVersion) => Body?.ResetPatchVersion(iVersion) ?? false;
        
        /// <summary>
        /// 上一补丁版本
        /// </summary>
        public ISAssetVersion LastPatchVersion => Body?.LastPatchVersion;

        /// <summary>
        /// 重置上一次母包版本
        /// </summary>
        /// <param name="iVersion">母包版本</param>
        /// <returns>true:有变化; false:无变化;</returns>
        public bool ResetLastPatchVersion(string iVersion) => Body?.ResetLastPatchVersion(iVersion) ?? false;

#endregion
        
    }
}
